$(function(){

    $("#mast").on("click",function(){
        var orginPass = $("[name='orginPass']").val();
        var newPass = $("[name='newPass']").val();
        var againPass = $("[name='againPass']").val();
        var vCode = $("[name='vCode']").val();

        if(!orginPass){
            mui.toast("请输入原密码");
            return;
        }
        if(!newPass){
            mui.toast("请输入新密码");
            return;
        }
        if(!vCode){
            mui.toast("请输入认证码");
            return;
        }

        $.ajax({
            type: "post",
            url: "/user/updatePassword",
            data: {
                oldPassword:orginPass,
                newPassword:newPass,
                vCode:vCode

            },
            success: function (res) {
                if(res.success){
                    mui.toast("修改成功");
                    setTimeout(function(){
                        location.href = "login.html";
                    },1000);
                }else{
                    mui.toast("修改失败，请重新修改");
                }
            }
        });
    });


    $(".getCode").on("click",function(){
        if($(this).hasClass("doing")){
            return;
        }
        var str = $(this).addClass("doing");
        console.log(str);
        $(this).text("正在请求...");
        var This = this;
        setTimeout(function(){
            $(This).removeClass("doing");
            $(This).text("获取认证码");
        },3000);

        $.ajax({
            type: "get",
            url: "/user/vCodeForUpdatePassword",
            success: function (response) {
                console.log(response);
            }
        });
    });

});